﻿import {addPromotuon, findPageCondition,findgood} from '../../../api/Promotion/promotion'

let brand = {
    data() {
        return {
            //申请单
            PromotionInfo: {
                promotionId: '',  //id序号
                promotionName: "",  //活动名字
                promotionStarttime: "",  //开始时间
                promotionStoptime: "",  //活动结束时间
                promotionType: "", //活动类型
                priceTaketime: "", //生效时间
                priceLosetime: "",//失效时间
                promotionFile: "", //上传文件地址
                promotionApplicant: "",//申请人
                promotionApplicanttime: "",//申请时间
                promotionRemarks: "", // 备注信息
                promotionApprover: "",  //审批人
                promotionApprovertime: "",  //审批时间
                promotionApprovalstatus: "",  //审批状态
                promotionApproveridea: "",  //审批意见

                goodId: "", //商品id
                goodName:"",  //商品名字
                goodStock:"", //库存数
                promotionNum:"", //促销数
                marketPrice:"", //市场价
                storePrice:"", //商城价
                adiustPriceWay: "",//调价方式
                promotionPrice: "",//促销价格
                percent: "" //调价百分比
            },

            findGoodInfo: {
                goodId:"",
                goodName: "",
                goodModel: "",
                goodColorid: "", //商品颜色
                goodBrandid: "", //品牌
                current: 1, //页数
                size: 5 //每页条数
            },

            selectedGood: false, //弹窗页

            goodInfo: [], //查询的商品信息
            goodInfo3: [], //确认的商品
            totalPage:0,  //总页数

            PriceWay:true,
        }
        // location.reload()
        // this.$router.go(0)
    },

    methods: {
        findGood() {  //查询所有商品
            findgood(this.findGoodInfo).then(response => {
                this.totalPage = response.total;
                this.goodInfo = response.data;
            })
        },
        findGood2() {  //确认商品
            findgood(this.findGoodInfo).then(response => {
                this.totalPage = response.total;
                this.goodInfo3 = response.data;
            })
        },
        pagefindgood(aaa){   //分页查询
            this.findGoodInfo.current=aaa;
            this.findGood()
        },
        affirm(goodId){  //确认商品
            this.findGoodInfo.goodId = goodId;
            this.selectedGood=false;
            this.findGood2()
        },
        backtrack() {  //返回
            this.$router.push({
                path: "/Promotion",
            })
        },
        addPromotion() {  //添加申请单
            this.PromotionInfo.goodId = this.goodInfo3[0].goodId;
            this.PromotionInfo.goodName = this.goodInfo3[0].goodName;
            this.PromotionInfo.goodStock = this.goodInfo3[0].goodStock;
            this.PromotionInfo.marketPrice = this.goodInfo3[0].goodMarketprice;  //市场价
            this.PromotionInfo.storePrice = this.goodInfo3[0].goodMallprice;  //商城价
            // this.PromotionInfo.adiustPriceWay = this.goodInfo3[0].adiustPriceWay;  //调价方式
            // this.PromotionInfo.promotionPrice = this.goodInfo3[0].promotionPrice;  //促销价格
            // this.PromotionInfo.percent = this.goodInfo3[0].goodId;  //百分比
            addPromotuon(this.PromotionInfo);
            this.$router.push("/Promotion")
        },
        restd(){  //复位
            this.findGoodInfo.goodName="";
            this.findGoodInfo.goodId="";
            this.findGoodInfo.goodModel="";
            this.findGoodInfo.goodColorid="";
            this.findGoodInfo.goodBrandid="";
        }
    },

    // created() {
    //     this.findGood()
    // }
};

export default brand;

